package com.web.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.web.entity.Course;
import com.web.entity.Student;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper extends BaseMapper<Student> {

    @Select("select * from student where id=#{id}")
    @Results({
            @Result(column="id",property="id",id=true),
            @Result(column = "name",property = "name"),
            @Result(column="id",property="courses",javaType= List.class,
                    many=@Many(
                            select="com.web.mapper.CourseMapper.queryCoursesByStuId"
                    )
            )
    })

    Student queryStuById(@Param("id") Integer id);


    List<Student> getStudentAndCourse();
}
